let OSS = require('ali-oss')

const ossclient = new OSS({
            endpoint:'oss-cn-hangzhou.aliyuncs.com', //端口
            bucket:'hnustpyw',
            accessKeyId:'LTAI5tGedGYp9sC9G26dsJJY', //AccessKey
            accessKeySecret: 'R3W751BpLNbiNUVtEnlVhansbvpFn0'//密钥
        });

export async function ossUpload(file){
	console.log(file)
	const filePaths = [];
	for(let i =0 ; i < file.length ; i++){
		const filePath = `upload/${uni.getStorageSync('studentNum')}/${file[i].name}`
		await ossclient.put(filePath ,file[i].uri).then(res =>{
			console.log(res)
			if(res.res.status == 200){
				filePaths.push(filePath + '/' +file[i].uri.name)
				console.log("上传到oss成功");
			}else{
				console.log("上传到oss失败");
			}
		})
	}
	return filePaths;
}
